﻿<?php
	$dbuser='root';
	$dbpassword='';
	$dbdatabase='jm24';
	
	$pdo=new PDO("mysql:host=localhost;port=3307;dbname={$dbdatabase}","{$dbuser}","{$dbpassword}");
	$pdo->exec('set names utf8');
	$sql='select * from tb_user_info';
	$smt=$pdo->query($sql);
	$rows=$smt->fetchAll(PDO::FETCH_ASSOC);
	
	//print_r($rows);
	
	//数据输入
	$input=array('username'=>' ','password'=>' ');
	$input['username']=$_POST['username'];
	$input['pwd']=$_POST['pwd'];
	$input['pwd']=sha1($input['pwd']);
	$error=1;
	
	//判断并返回
	foreach($rows as $row){
		if($row['USERNAME']==$input['username'] && $row['PWD']==$input['pwd']){
			$jsonData=array('code'=>'200');
			$error=0;
			break;
		}
	}
	
	if($error==1){
		$jsonData=array('code'=>'1');
	}
	
	echo json_encode($jsonData);
?>